package com.neu.mapper;


import com.neu.pojo.Student;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.util.List;
import java.util.Map;

@Mapper
public interface StudentMapper {



    List<Student> page(String name, Integer degree, Integer clazzId);

    @Insert("insert into student(name,no,gender,phone,id_card,is_college,address,degree,graduation_date,clazz_id,create_time,update_time)" +
            "values (#{name},#{no},#{gender},#{phone},#{idCard},#{isCollege},#{address},#{degree},#{graduationDate},#{clazzId},#{createTime},#{updateTime})")
    void save(Student student);

    @Delete("delete from student where id=#{id}")
    void deleteById(Integer id);

    @Select("select * from student where id=#{id}")
    Student getById(Integer id);

    void update(Student student);

    @Update("update student\n" +
            "set violation_count = violation_count +1,\n" +
            "\t  violation_score = violation_score + #{score}\n" +
            "where id = #{id}")
    void updateViolate(Integer id, Short score);

    List<Map<String, Object>> countStudentDegreeData();
}
